import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    // 当设置 true 的时候该路由不会在侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name:"Layout",
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '主页', icon: 'el-icon-position' },
      },

      {
        path: 'report',
        name: 'Report',
        component: () => import('@/views/reportTable/index.vue'),
        meta: { title: 'reportTable', icon: 'el-icon-position'},

      },

      {
        path: 'testDetail',
        name: 'TestDetail',
        component: () => import('@/views/testDetailTable/index.vue'),
        meta: { title: 'testDetail', icon: 'el-icon-position'},

      },

      {
        path: 'historyTable',
        name: 'HistoryTable',
        component: () => import('@/views/testDetailTable/historyTable.vue'),
        meta: { title: 'historyTable', icon: 'el-icon-position',activeMenu:"testDetail"},

      },

      {
        path: 'pydetail',
        name: 'Pydetail',
        component: () => import('@/views/testDetailTable/pydetail.vue'),
        meta: { title: 'pydetail', icon: 'el-icon-position',activeMenu:"testDetail"},

      },
      {
        path: 'msdetail',
        name: 'Msdetail',
        component: () => import('@/views/testDetailTable/msdetail.vue'),
        meta: { title: 'msdetail', icon: 'el-icon-position',activeMenu:"testDetail"},

      },
      {
        path: 'onlinInspection',
        name: 'OnlinInspection',
        component: () => import('@/views/onlinInspection/index.vue'),
        meta: { title: '线上巡检', icon: 'el-icon-position'},

      },
      {
        path: 'onlineDetail',
        name: 'OnlineDetail',
        component: () => import('@/views/onlinInspection/onlineDetail.vue'),
        meta: { title: '线上巡检', icon: 'el-icon-position',activeMenu:"onlinInspection"}

      },
   /*   {
        path: 'task',
        name: 'Task',
        component: () => import('@/views/apply/task.vue'),
        meta: { title: '任务', icon: 'el-icon-position' ,},//activeMenu:"apply"
      },
      {
        path: 'process',
        name: 'Process',
        component: () => import('@/views/apply/process.vue'),
        meta: { title: '流程', icon: 'el-icon-position' ,activeMenu:"apply"},//activeMenu:"apply"
      },*/


    ]
  },


  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]
export const asyncRoutes =
  {
    // 'releaseNote': {
    //   path: 'releaseNote',
    //   name: 'releaseNote',
    //   text: '发版说明',
    //   component: () => import('@/views/releaseNote/index'),
    //   meta: {
    //     title: '发版说明'
    //   }
    // }
  }
function createRouter() {
  return new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }), // 页面跳转时的y轴移动的距离
    routes: constantRoutes
  })
}

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher //路由重置
}

export default router
